// Copyright (c) 2024 CHANGLEI. All rights reserved.

import 'package:charts_grasp/src/chart/axis/axis.dart';
import 'package:charts_grasp/src/chart/chart_series/xy_data_series.dart';
import 'package:charts_grasp/src/chart/common/data_label.dart';
import 'package:charts_grasp/src/chart/common/interactive_tooltip.dart';
import 'package:charts_grasp/src/chart/technical_indicators/technical_indicator.dart';
import 'package:charts_grasp/src/chart/utils/enum.dart';
import 'package:charts_grasp/src/common/utils/enum.dart';
import 'package:flutter/material.dart';

class TooltipArgs {
  TooltipArgs([this.seriesIndex, this.dataPoints, this.viewportPointIndex, this.pointIndex]);

  String? text;

  String? header;

  double? locationX;

  double? locationY;

  final dynamic seriesIndex;

  final List<dynamic>? dataPoints;

  final num? pointIndex;

  final num? viewportPointIndex;
}

class ActualRangeChangedArgs {
  ActualRangeChangedArgs(
      [this.axisName, this.axis, this.actualMin, this.actualMax, this.actualInterval, this.orientation,]);

  final String? axisName;

  final ChartAxis? axis;

  final dynamic actualMin;

  final dynamic actualMax;

  final dynamic actualInterval;

  dynamic visibleMin;

  dynamic visibleMax;

  dynamic visibleInterval;

  final AxisOrientation? orientation;
}

class AxisLabelRenderDetails {
  AxisLabelRenderDetails(
      this.value, this.text, this.textStyle, this.axis, this.currentDateTimeIntervalType, this.currentDateFormat,);

  final String text;

  final num value;

  final ChartAxis axis;

  final TextStyle textStyle;

  final DateTimeIntervalType? currentDateTimeIntervalType;

  final String? currentDateFormat;
}

class MultiLevelLabelRenderDetails {
  MultiLevelLabelRenderDetails(this.actualLevel, this.text, this.textStyle, this.index, this.axisName);

  final String text;

  final TextStyle textStyle;

  final int index;

  final int actualLevel;

  final String? axisName;
}

class ChartAxisLabel {
  ChartAxisLabel(this.text, TextStyle? textStyle)
      : textStyle = textStyle ??
            const TextStyle(
                fontFamily: 'Roboto', fontStyle: FontStyle.normal, fontWeight: FontWeight.normal, fontSize: 12,);

  final String text;

  final TextStyle textStyle;
}

class DataLabelRenderArgs {
  DataLabelRenderArgs([this.seriesRenderer, this.dataPoints, this.viewportPointIndex, this.pointIndex]);

  late String text;

  TextStyle? textStyle;

  final dynamic seriesRenderer;

  final dynamic dataPoints;

  final int? pointIndex;

  Color? color;

  Offset? offset;

  final int? viewportPointIndex;
}

class LegendRenderArgs {
  LegendRenderArgs([this.seriesIndex, this.pointIndex]);

  String? text;

  LegendIconType? legendIconType;

  final int? seriesIndex;

  final int? pointIndex;

  Color? color;
}

class TrendlineRenderParams {
  TrendlineRenderParams(
      [this.intercept,
      this.seriesIndex,
      this.trendlineName,
      this.seriesName,
      this.calculatedDataPoints,
      this.slope,
      this.rSquaredValue,]);

  final double? intercept;

  final int? seriesIndex;

  final String? trendlineName;

  final String? seriesName;

  final List<Offset>? calculatedDataPoints;

  final double? rSquaredValue;

  final List<double>? slope;
}

class TrackballArgs {
  ChartPointInfo chartPointInfo = ChartPointInfo();
}

class CrosshairRenderArgs {
  CrosshairRenderArgs([this.axis, this.value, this.axisName, this.orientation]);

  final ChartAxis? axis;

  late String text;

  late Color lineColor;

  final dynamic value;

  final String? axisName;

  final AxisOrientation? orientation;
}

class ChartTouchInteractionArgs {
  late Offset position;
}

class ZoomPanArgs {
  ZoomPanArgs([this.axis, this.previousZoomPosition, this.previousZoomFactor]);

  final ChartAxis? axis;

  late double currentZoomPosition;

  late double currentZoomFactor;

  final double? previousZoomPosition;

  final double? previousZoomFactor;
}

class ChartPointDetails {
  ChartPointDetails([this.seriesIndex, this.viewportPointIndex, this.dataPoints, this.pointIndex]);

  final int? seriesIndex;

  final int? pointIndex;

  final List<dynamic>? dataPoints;

  final num? viewportPointIndex;
}

class AxisLabelTapArgs {
  AxisLabelTapArgs([this.axis, this.axisName]);

  final ChartAxis? axis;

  late String text;

  late num value;

  final String? axisName;
}

class LegendTapArgs {
  LegendTapArgs([this.series, this.seriesIndex, this.pointIndex]);

  final dynamic series;

  final int? seriesIndex;

  final int? pointIndex;
}

class SelectionArgs {
  SelectionArgs(
      {required this.seriesRenderer,
      required this.seriesIndex,
      required this.viewportPointIndex,
      required this.pointIndex,});

  final dynamic seriesRenderer;

  Color? selectedColor;

  Color? unselectedColor;

  Color? selectedBorderColor;

  double? selectedBorderWidth;

  Color? unselectedBorderColor;

  double? unselectedBorderWidth;

  final int seriesIndex;

  final int pointIndex;

  final int viewportPointIndex;
}

@Deprecated('Use IndicatorRenderParams instead.')
class IndicatorRenderArgs {
  @Deprecated('Use IndicatorRenderParams instead.')
  IndicatorRenderArgs([
    this.indicator,
    this.index,
    this.seriesName,
    this.dataPoints,
  ]);

  final TechnicalIndicators<dynamic, dynamic>? indicator;

  late String indicatorName;

  final int? index;

  late Color signalLineColor;

  late double signalLineWidth;

  late List<double> lineDashArray;

  final String? seriesName;

  final List<dynamic>? dataPoints;
}

class MarkerRenderArgs {
  MarkerRenderArgs([this.viewportPointIndex, this.seriesIndex, this.pointIndex]);

  final int? pointIndex;

  final int? seriesIndex;

  late DataMarkerType shape;

  late double markerWidth;

  late double markerHeight;

  Color? color;

  Color? borderColor;

  late double borderWidth;

  final num? viewportPointIndex;
}

class DataLabelTapDetails {
  DataLabelTapDetails(this.seriesIndex, this.viewportPointIndex, this.text, this.dataLabelSettings, this.pointIndex);

  late Offset position;

  final int seriesIndex;

  final int pointIndex;

  final String text;

  final DataLabelSettings dataLabelSettings;

  final int viewportPointIndex;
}

class ChartShaderDetails {
  ChartShaderDetails(this.outerRect, this.innerRect, this.renderType);

  final Rect outerRect;

  final String renderType;

  final Rect? innerRect;
}

class ShaderDetails {
  ShaderDetails(this.rect, this.renderType);

  final Rect rect;

  final String renderType;
}

class IndicatorRenderParams {
  IndicatorRenderParams(
      this.calculatedDataPoints, this.name, this.signalLineWidth, this.signalLineColor, this.signalLineDashArray,);

  final List<CartesianChartPoint<dynamic>>? calculatedDataPoints;

  late double signalLineWidth;

  late Color signalLineColor;

  final String name;

  late List<double> signalLineDashArray;
}

class BollingerBandIndicatorRenderParams extends IndicatorRenderParams {
  BollingerBandIndicatorRenderParams(
      this.upperLineValues,
      this.lowerLineValues,
      List<CartesianChartPoint<dynamic>>? calculatedDataPoints,
      String name,
      double signalLineWidth,
      Color signalLineColor,
      List<double> signalLineDashArray,)
      : super(calculatedDataPoints, name, signalLineWidth, signalLineColor, signalLineDashArray);

  final List<CartesianChartPoint<dynamic>>? upperLineValues;

  final List<CartesianChartPoint<dynamic>>? lowerLineValues;
}

class MomentumIndicatorRenderParams extends IndicatorRenderParams {
  MomentumIndicatorRenderParams(this.centerLineValue, List<CartesianChartPoint<dynamic>>? calculatedDataPoints,
      String name, double signalLineWidth, Color signalLineColor, List<double> signalLineDashArray,)
      : super(calculatedDataPoints, name, signalLineWidth, signalLineColor, signalLineDashArray);

  final double? centerLineValue;
}

class StochasticIndicatorRenderParams extends IndicatorRenderParams {
  StochasticIndicatorRenderParams(this.periodLineValues, List<CartesianChartPoint<dynamic>>? calculatedDataPoints,
      String name, double signalLineWidth, Color signalLineColor, List<double> signalLineDashArray,)
      : super(calculatedDataPoints, name, signalLineWidth, signalLineColor, signalLineDashArray);

  final List<CartesianChartPoint<dynamic>>? periodLineValues;
}

class MacdIndicatorRenderParams extends IndicatorRenderParams {
  MacdIndicatorRenderParams(
      this.macdLineValues,
      this.macdHistogramValues,
      List<CartesianChartPoint<dynamic>>? calculatedDataPoints,
      String name,
      double signalLineWidth,
      Color signalLineColor,
      List<double> signalLineDashArray,)
      : super(calculatedDataPoints, name, signalLineWidth, signalLineColor, signalLineDashArray);

  final List<CartesianChartPoint<dynamic>>? macdLineValues;

  final List<CartesianChartPoint<dynamic>>? macdHistogramValues;
}

class TechnicalIndicatorRenderDetails {
  TechnicalIndicatorRenderDetails(this.signalLineColor, this.signalLineWidth, this.signalLineDashArray);

  final Color? signalLineColor;

  final double? signalLineWidth;

  final List<double>? signalLineDashArray;
}

class ErrorBarRenderDetails {
  ErrorBarRenderDetails(this.pointIndex, this.viewPortPointIndex, this.calculatedErrorBarValues);

  final int? pointIndex;

  final int? viewPortPointIndex;

  final ErrorBarValues? calculatedErrorBarValues;
}

class ErrorBarValues {
  ErrorBarValues(
    this.horizontalPositiveErrorValue,
    this.horizontalNegativeErrorValue,
    this.verticalPositiveErrorValue,
    this.verticalNegativeErrorValue,
  );

  final double? horizontalPositiveErrorValue;

  final double? horizontalNegativeErrorValue;

  final double? verticalPositiveErrorValue;

  final double? verticalNegativeErrorValue;
}
